import javax.swing.plaf.synth.SynthOptionPaneUI;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ASUS
 * Date: 2022-08-03
 * Time: 11:19
 */
public class Test {
    /**
     *
     * @param pos1 起始位置
     * @param pos2 中转位置
     * @param pos3int 结束位置
     */

    public static void hanio(int n,char pos1, char pos2, char pos3){
        if(n == 1){
            move(pos1,pos3);
            return;
        }
        hanio(n-1,pos1,pos3,pos2);
        move(pos1,pos3);
        hanio(n-1,pos2,pos1,pos3);

    }
    /**
     *
     * @param pos1 起始位置
     * @param pos2 目标位置
     */

    public static  void move(char pos1, char pos2){
        System.out.print(pos1+"->"+pos2+" ");

    }

    public static void main(String[] args) {
        hanio(1,'A','B','C');
        System.out.println();
        hanio(2,'A','B','C');
        System.out.println();
        hanio(3,'A','B','C');
    }
}
